import { getIndexData } from '@/service/koding';

export default {
  namespace: 'koding/index',
  state: {
    index_data: {},
  },
  effects: {
    *getIndexData({}: any, { put, call }: any) {
      const ret = yield call(getIndexData);
      if (ret.errno === 0) {
        yield put({
          type: 'setIndexData',
          ret,
        });
      }
    },
  },
  reducers: {
    setIndexData(state: any, { ret }: any) {
      return { ...state, index_data: ret.data };
    },
  },
};
